// 登录功能
const login = document.querySelector('#btn-login')
console.log(login)
login.addEventListener('click', function () {
    const form = document.querySelector('#log-form')
    const data = serialize(form)
    axios.post('/login', data)
        .then(({ data }) => {
            console.log(data)
            if (data.message === "登录成功") {
                tip(data.message)
                localStorage.setItem('user-token', data.data.token)
                localStorage.setItem('user-name', data.data.username)
                setTimeout(function () {
                    location.href = '/index.html'
                }, 2000)
            } else {
                tip(data.message)
            }
        })
        .catch(err => {
            tip(err.response.data.message)
        })
})